package com.tac.controller.wms;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.wms.TransferInformation;
import com.tac.service.wms.TransferInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/transferInformation")
@CrossOrigin
@Api(tags = "智能仓储WMS--移库信息")
public class TransferInformationController {

    @Autowired
    private TransferInformationService transferInformationService;

    // 移库信息查询
    @ApiOperation("移库信息查询")
    @GetMapping("/getList")
    public Result<PageInfo<TransferInformation>> getList(Integer pageNum, Integer pageSize, String material, String batchNumber, String sourceWarehouse,
                                                         String sourceStorageArea, String sourceLocation, String targetWarehouse,
                                                         String targetStorageArea, String targetLocation, @DateTimeFormat(pattern = "yyyy-MM-dd")Date transferTimeStart,
                                                         @DateTimeFormat(pattern = "yyyy-MM-dd")Date transferTimeEnd, String executor) {
        return transferInformationService.getList(pageNum, pageSize, material,batchNumber,sourceWarehouse,sourceStorageArea,sourceLocation,targetWarehouse
                ,targetStorageArea,targetLocation,transferTimeStart,transferTimeEnd,executor);
    }

    // 移库信息添加
    @ApiOperation("移库信息添加")
    @PostMapping("/save")
    public Result save(@RequestBody TransferInformation transferInformation) {
        return transferInformationService.save(transferInformation);
    }

    // 移库信息删除
    @ApiOperation("移库信息删除")
    @DeleteMapping("/remove")
    public Result remove(@RequestBody List<Integer> ids) {
        return transferInformationService.remove(ids);
    }

    // 移库信息更新
    @ApiOperation("移库信息更新")
    @PutMapping("/update")
    public Result update(@RequestBody TransferInformation transferInformation) {
        return transferInformationService.update(transferInformation);
    }
}
